﻿@using Abp.Authorization.Users
@using Abp.MultiTenancy
@using Abp.Web.Mvc.Extensions
@using AbpCompanyName.AbpProjectName.MultiTenancy
@model Abp.Application.Services.Dto.PagedResultDto<AbpCompanyName.AbpProjectName.MultiTenancy.Dto.TenantDto>
@{
    ViewBag.ActiveMenu = PageNames.Tenants; //The menu item will be active for this page.
}
@section scripts
{
    @Html.IncludeScript("~/Views/Tenants/Index.js")
}
<div class="row clearfix">
    <div class="col-lg-12 col-md-12 col-sm-12 col-xs-12">
        <div class="card">
            <div class="header">
                <h2>
                    @L("Tenants")
                </h2>
                <ul class="header-dropdown m-r--5">
                    <li class="dropdown">
                        <a href="javascript:void(0);" class="dropdown-toggle" data-toggle="dropdown" role="button" aria-haspopup="true" aria-expanded="false">
                            <i class="material-icons">more_vert</i>
                        </a>
                        <ul class="dropdown-menu pull-right">
                            <li><a id="RefreshButton" href="javascript:void(0);" class="waves-effect waves-block"><i class="material-icons">refresh</i>Refresh</a></li>
                        </ul>
                    </li>
                </ul>
            </div>
            <div class="body table-responsive">
                <table class="table">
                    <thead>
                        <tr>
                            <th>@L("TenancyName")</th>
                            <th>@L("Name")</th>
                            <th>@L("IsActive")</th>
                        </tr>
                    </thead>
                    <tbody>
                        @foreach (var tenant in Model.Items)
                        {
                            <tr>
                                <td>@tenant.TenancyName</td>
                                <td>@tenant.Name</td>
                                <td><i class="material-icons" style="color:@(tenant.IsActive ? "green":"red");">@(tenant.IsActive ? "check_box" : "indeterminate_check_box")</i></td>
                                <td class="dropdown">
                                    <a href="#" class="dropdown-toggle" data-toggle="dropdown" role="button" aria-haspopup="true" aria-expanded="false">
                                        <i class="material-icons">menu</i>
                                    </a>
                                    <ul class="dropdown-menu pull-right">
                                        <li><a href="#" class="waves-effect waves-block edit-tenant" data-tenant-id="@tenant.Id" data-toggle="modal" data-target="#TenantEditModal"><i class="material-icons">edit</i>@L("Edit")</a></li>
                                        <li><a href="#" class="waves-effect waves-block delete-tenant" data-tenant-id="@tenant.Id" data-tenancy-name="@tenant.TenancyName"><i class="material-icons">delete_sweep</i>@L("Delete")</a></li>
                                    </ul>
                                </td>
                            </tr>
                        }
                    </tbody>
                </table>
                <button type="button" class="btn btn-primary btn-circle waves-effect waves-circle waves-float pull-right" data-toggle="modal" data-target="#TenantCreateModal">
                    <i class="material-icons">add</i>
                </button>
            </div>
        </div>
    </div>
</div>

<div class="modal fade" id="TenantCreateModal" tabindex="-1" role="dialog" aria-labelledby="TenantCreateModalLabel" data-backdrop="static">
    <div class="modal-dialog" role="document">
        <div class="modal-content">
            <form name="tenantCreateForm" role="form" novalidate class="form-validation">
                <div class="modal-header">
                    <h4 class="modal-title">
                        <span>@L("CreateNewTenant")</span>
                    </h4>
                </div>
                <div class="modal-body">
                    <div class="form-group form-float">
                        <div class="form-line">
                            <input class="form-control" type="text" name="TenancyName" required maxlength="@AbpTenantBase.MaxTenancyNameLength" minlength="2">
                            <label class="form-label">@L("TenancyName")</label>
                        </div>
                    </div>
                    <div class="form-group form-float">
                        <div class="form-line">
                            <input type="text" name="Name" class="form-control" required maxlength="@Tenant.MaxNameLength">
                            <label class="form-label">@L("Name")</label>
                        </div>
                    </div>
                    <div class="form-group form-float">
                        <div class="form-line">
                            <input type="text" name="ConnectionString" class="form-control" maxlength="@AbpTenantBase.MaxConnectionStringLength">
                            <label class="form-label">@L("DatabaseConnectionString") (@L("Optional"))</label>
                        </div>
                    </div>
                    <div class="form-group form-float">
                        <div class="form-line">
                            <input type="email" name="AdminEmailAddress" class="form-control" required maxlength="@AbpUserBase.MaxEmailAddressLength">
                            <label class="form-label">@L("AdminEmailAddress")</label>
                        </div>
                    </div>
                    <div class="checkbox">
                        <input type="checkbox" name="IsActive" value="true" id="CreateTenantIsActive" class="filled-in" checked />
                        <label for="CreateTenantIsActive">@L("IsActive")</label>
                    </div>
                    <p>@L("DefaultPasswordIs", AbpCompanyName.AbpProjectName.Authorization.Users.User.DefaultPassword)</p>
                </div>
                <div class="modal-footer">
                    <button type="button" class="btn btn-default waves-effect" data-dismiss="modal">@L("Cancel")</button>
                    <button type="submit" class="btn btn-primary waves-effect">@L("Save")</button>
                </div>
            </form>
        </div>
    </div>
</div>

<div class="modal fade" id="TenantEditModal" tabindex="-1" role="dialog" aria-labelledby="TenantEditModalLabel" data-backdrop="static">
    <div class="modal-dialog" role="document">
        <div class="modal-content">

        </div>
    </div>
</div>